package com.qf.controller;

import com.qf.pojo.Stu;
import com.qf.service.StuService;
import com.qf.utis.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/stu")
public class StuController {
    @Autowired
    private  StuService stuService;
    //根据id查询
    @RequestMapping("/getById")
    public R getById(Integer id){
        return stuService.getById(id);
    }
    //查询所有
    @RequestMapping("/getAll")
    public R getAll(){
        return stuService.getAll();
    }
    //根据条件模糊查询全部数据
    @RequestMapping("/getAllByCondition")
    public R getAllByCondition(@RequestParam HashMap<String,Object>  map){
        return stuService.getAllByCondition(map);
    }
    //添加
    @RequestMapping("/add")
    public R add(Stu stu){
        return stuService.add(stu);
    }
    //修改
    @RequestMapping("/update")
    public R update(Stu stu){
        return stuService.update(stu);
    }
    //删除
    @RequestMapping("/delete")
    public R delete(Integer id){
        return stuService.delete(id);
    }
    //批量删除
    @RequestMapping("/deleteBatch")
    public R deleteBatch(@RequestParam List< Integer> ids){
        return stuService.deleteBatch(ids);
    }
    //查询所有学生并关联班级信息
    @RequestMapping("/getAllStuAndClass")
    public R getAllStuAndClass(){
        return stuService.getAllStuAndClass();
    }
    //根据学生ID学生及其所选所有科目信息
    @RequestMapping("/getStuAndALLSubject")
    public R getStuAndALLSubject(Integer id){
        return stuService.getStuAndALLSubject(id);
    }
    //根据学生ID查找学生信息及其所有科目信息以及科目对应的老师信息
    @RequestMapping("/getStuAndALLSubjectAndTeacher")
    public R getStuAndALLSubjectAndTeacher(Integer id){
        return stuService.getStuAndALLSubjectAndTeacher(id);
    }

}
